package com.yanggu.scala.chapater14

/**
 * 反转字符串
 */
object RecursiveDemo04 {

  def main(args: Array[String]): Unit = {

    //Str = "ab"
    def reverse(xs: String): String =
      if (xs.length == 1)
        xs
      else
        reverse(xs.tail) + xs.head

    val str = "abc"

    println(reverse(str))
  }

}
